'''
Author: linxuan
Date: 2022-07-16 20:29:43
Description: file content
FilePath: /stealer/src/h5.zycn.vip_upload.py
'''
import json
import time
from upload import upload


def generate_zycn_params(item: dict) -> dict:
    params = dict()
    params['collection'] = '数字艺术'
    params['name'] = item['nft_name']
    params['author'] = '中艺数藏'
    params['date'] = time_str = time.strftime('%Y-%m-%d', time.localtime(item['publish_time']))
    params['amount'] = item['publish_num']
    params['type'] = 'picture'
    params['platform'] = '中艺数藏'
    params['price'] = item['market_price']
    params['token_id'] = item['nft_token']
    params['content_url'] = 'https://cdn.zycn.vip' + item['nft_icon'] + '_homegood'
    params['discription'] = item['nft_intro']
    params['origin_link'] = f'https://h5.zycn.vip/pages/market/detail?id={item["id"]}'
    return params


if __name__ == '__main__':
    # 遍历/resources/zycn目录下的所有文件json
    with open("/info.json"[1:]) as f:
        info = json.load(f)
        params = generate_zycn_params(info['data']['info'])
        ok, err = upload(params)
        print(ok, err)
